<?php

/**
 * This is the model class for table "slider_banner".
 *
 * The followings are the available columns in table 'slider_banner':
 * @property integer $id
 * @property string $title
 * @property string $image
 * @property string $type
 * @property string $image_link
 * @property string $image_link_target
 * @property string $info_text
 * @property string $info_text_link
 * @property string $info_text_link_title
 * @property string $info_text_link_target
 * @property integer $sort
 * @property integer $is_active
 */
class SliderBanner extends CActiveRecord
{
	public function tableName()
	{
		return 'slider_banner';
	}

	public function rules()
	{
		return array(
			array('image', 'required'),
			array('sort, is_active', 'numerical', 'integerOnly'=>true),
			array('title, image, image_link, info_text, info_text_link', 'length', 'max'=>255),
			array('type', 'length', 'max'=>50),
			array('image_link_target, info_text_link_target', 'length', 'max'=>20),
			array('info_text_link_title', 'length', 'max'=>100),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, title, image, type, image_link, image_link_target, info_text, info_text_link, info_text_link_title, info_text_link_target, sort, is_active', 'safe', 'on'=>'search'),
		);
	}

	public function relations()
	{
		return array(
		);
	}

	public function attributeLabels()
	{
		return array(
            'id'=>Yii::t('modules/maine','id'),
            'title'=>Yii::t('modules/maine','name'),
            'image'=>Yii::t('modules/maine','image'),
            'type'=>Yii::t('modules/slider','type'),
            'image_link'=>Yii::t('modules/slider','imageLink'),
            'image_link_target'=>Yii::t('modules/slider','imageLinkType'),
            'info_text'=>Yii::t('modules/slider','textInfoBlock'),
            'info_text_link'=>Yii::t('modules/slider','linkInfoBlock'),
            'info_text_link_title'=>Yii::t('modules/slider','nameLinkInfoBlock'),
            'info_text_link_target'=>Yii::t('modules/slider','typeLinkInfoBlock'),
            'sort'=>Yii::t('modules/maine','sortOrder'),
            'is_active'=>Yii::t('modules/maine','isActive'),
		);
	}

	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('image',$this->image,true);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('image_link',$this->image_link,true);
		$criteria->compare('image_link_target',$this->image_link_target,true);
		$criteria->compare('info_text',$this->info_text,true);
		$criteria->compare('info_text_link',$this->info_text_link,true);
		$criteria->compare('info_text_link_title',$this->info_text_link_title,true);
		$criteria->compare('info_text_link_target',$this->info_text_link_target,true);
		$criteria->compare('sort',$this->sort);
		$criteria->compare('is_active',$this->is_active);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
